export function hasLogin(){
	let userInfoStr = uni.getStorageSync("userInfo");
	return !!userInfoStr; // 如果有userInfo，则返回true，表示已登录；否则返回false
}

export function checkLogin(){
	let userInfo = uni.getStorageSync("userInfo");
	if(!userInfo){
		uni.showToast({
			title: "请先登录",
			icon: "error",
			duration: 2000
		});
		uni.removeStorageSync('userInfo'); // 可选：清除已失效或不存在的userInfo缓存
		    uni.redirectTo({
		      url: "/pages/login/login"
		});
	}
}

export function getUserid(){
	let userInfoStr = uni.getStorageSync("userInfo");
	let userInfo = userInfoStr ? JSON.parse(userInfoStr) : null;
	return userInfo && userInfo.userid ? userInfo.userid : '';
}


